<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<jsp:include page="/admin/common/css/style_sub.jsp"></jsp:include>
<link rel="stylesheet" type="text/css" href="<%=basePath%>js/lib/validation/css/livevalidation.css"/>
<script type="text/javascript" src="<%=basePath%>js/lib/validation/livevalidation.js"></script>
<script type="text/javascript" src="<%=basePath%>js/lib/jquery/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="<%=basePath%>js/public.js"></script>
<script language="javascript">
$(function(){
	 var num = 500;  
	    //$("#message").html("还可以输入"+num+"个字符");
	    getEditedNum(num);
	    $("#remark").keyup(function(){getEditedNum(num);});
	checkAll();
});
function checkAll(){
	var name = new LiveValidation('name',{onlyOnSubmit:true});
	name.add( Validate.Presence, {failureMessage: "不能为空!"});
	name.add( Validate.Length, { maximum: 100} );
	var value_type = new LiveValidation('value_type',{onlyOnSubmit:true});
	value_type.add( Validate.Presence, {failureMessage: "不能为空!"});
	var key = new LiveValidation('key',{onlyOnSubmit:true});
	key.add( Validate.Presence, {failureMessage: "不能为空!"});
	key.add( Validate.Length, { maximum: 50} );
	var value = new LiveValidation('value',{onlyOnSubmit:true});
	value.add( Validate.Presence, {failureMessage: "不能为空!"});
	value.add( Validate.Length, { maximum: 500} );
	var editable = new LiveValidation('editable',{onlyOnSubmit:true});
	editable.add( Validate.Presence, {failureMessage: "不能为空!"});
	var visible = new LiveValidation('visible',{onlyOnSubmit:true});
	visible.add( Validate.Presence, {failureMessage: "不能为空!"});
}
function getEditedNum(num){ 
	
    var len = $("#remark").html().length; 
    var tmp = num - len;
    if(tmp<=0){  
    	$("#remark").html($("#remark").html().substring(0,num));  
        $("#message").html("还可以输入0个字符");
    }else{  
    	$("#message").html("还可以输入"+tmp+"个字符");  
    }
}
function goback(){
	window.location = "<%=basePath%>basic/sys/config_toConfigPage.action";
}
</script>
</head>
<body>
	<div class="title">新增系统参数</div>
	<form action="<%=basePath%>basic/sys/config_addConfig.action" id="form" method="post">
	<div class="editorTab">
		<table>
			<tbody>
				<tr>
					<th><font>*</font>参数名称</th>
					<td>
						<input type="text" name="sysConfig.name" id="name"/>
					</td>
					<th><font>*</font>数据类型</th>
						<td>
							<select name="sysConfig.value_type" id="value_type">
								<option value="">---请选择---</option>
								<option value="1">数字</option>
								<option value="2">字符串</option>
								<option value="3">布尔</option>
							</select>
						</td>
				</tr>
				<tr>
					<th><font>*</font>参数代码</th>
					<td>
						<input type="text" name="sysConfig.key" id="key"/>
					</td>
					<th>参&nbsp;&nbsp;数&nbsp;&nbsp;值</th>
					<td>
						<input type="text" name="sysConfig.value" id="value"/>
					</td>
				</tr>
				<tr>
						<th>说明</th>
						<td colspan="3">
						<textarea rows="5" cols="100%" name="sysConfig.remark" id="remark"></textarea>
						<div id="message"></div>
						</td>
					</tr>
				<tr>
					<th><font>*</font>是否可编辑</th>
						<td>
							<select name="sysConfig.editable" id="editable">
							    <option value="">---请选择---</option>
								<option value="0">否</option>
								<option value="1">是</option>
							</select>
						</td>
					<th><font>*</font>是否可见</th>
						<td>
							<select name="sysConfig.visible">
							    <option value="">---请选择---</option>
								<option value="0">否</option>
								<option value="1">是</option>
							</select>
						</td>
				</tr>
			</tbody>
		</table>
	</div>
	<div class="btns">
		<span class="btn"><input type="submit" value="提交"/></span>
		<span class="btn"><input type="button" value="关闭窗口" onclick="goback();"/></span>
	</div>
	</form>
</body>
</html>
